message loop
GUI programs process messages in a message loop. The message loop is usually the last three lines in the entry function of GUI programs. In fact, the entry function of most GUI programs are almost identical to the following example:

FUNCTION Entry ()
  SHARED terminateProgram
  STATIC entered
'
  IF entered THEN RETURN
  entered = $$TRUE
'
  Xui() ' initialize GuiDesigner
  InitGui() ' initialize message variables
  InitProgram() ' initialize this program
  CreateWindows() ' create program windows
  InitWindows() ' initialize windows
  IF LIBRARY(0) THEN RETURN ' libraries don't execute message loop
'
  DO ' begin the message loop ...
    XgrProcessMessages ( 1 ) ' process one message ...
  LOOP UNTIL terminateProgram ' repeat until program is terminated
END FUNCTION

Entry() initializes GuiDesigner and itself, then creates, activates, and displays its main window.  Finally it falls into its message loop, where it stays until the program is terminated.

The message loop is the "base of operations" for GUI programs.  Until the user operates the keyboard or mouse, programs sleep in XgrProcessMessages(1).   Computer time is given to other programs that have work to do.

When the user finally gets around to operating the GUI, GraphicsDesigner creates a message, puts it in the queue, and wakes up XgrProcessMessages(1) .

XgrProcessMessages(1) processes a message, then LOOP loops back to XgrProcessMessages(1) , where it awaits the next message.

Only when your program assigns a non-zero value to shared variable terminateProgram does the message loop end, usually followed by the entry function and the program.

But how does XgrProcessMessages(1) "process a message"?

What does it mean, to "process a message"?